<template>
	<view class="msg-item" @tap.stop="itemClk">
		<view class="system-msg" v-if="type == 2 || type == 3 || type == 5">
			<!-- 1：申请添加好友添加消息  2：添加好友成功的系统通知 3：公告 4：聊天消息通知  5：点评消息通知 -->
			<view class="msg-title">{{ type == 5?'您有一条被点评消息':'系统消息'}}</view>
			<view class="msg-time">{{msgData.createdTime}}</view>
			<view class="msg-text" v-if="type == 2">您已成功添加<text class="friend-name">{{ msgData.fromUserName }}</text>为好友</view>
			<view class="msg-text" v-else-if="type == 5">{{msgData.fromUserName }}点评了你</view>
			<view class="msg-text" v-else>{{ msgData.msgRemark }}</view>
			
			<view class="msg-notread" v-if="!msgData.isRead"></view>
		</view>
		
		<view class="user-msg" v-if="type == 1 || type == 4 || type == 6 || type == 7 || type == 8 || type == 9">
			<view class="user-msg-top">
				<image class="user-avatar" :src="getImgUrl(msgData.fromAvatar)"></image>
				<view class="msg-title-time">
					<view class="msg-title" v-if="type == 1"><text class="user-name">{{msgData.fromUserName}}</text>申请添加好友</view>
					<view class="msg-title" v-else-if="type == 6"><text class="user-name">{{msgData.fromUserName}}</text>分享了一条点评</view>
					<view class="msg-title" v-else-if="type == 7"><text class="user-name">{{msgData.fromUserName}}</text>请求分享您发过的一条点评</view>
					<view class="msg-title" v-else-if="type == 8"><text class="user-name">{{msgData.fromUserName}}</text>申请添加您的被评人为好友</view>
					<view class="msg-title" v-else-if="type == 9"><text class="user-name">{{msgData.fromUserName}}</text>通过好友点评申请添加您为好友</view>
					<view class="msg-title" v-else>{{msgData.fromUserName}}</view>
					<view class="msg-time">{{msgData.createdTime}}</view>
				</view>
			</view>
			<view class="user-msg-text" v-if="type == 4">HI，你好，很高兴能认识你~</view>
			<view class="user-msg-num" v-if="type == 4">1</view>
			<view class="msg-notread" v-if="type != 4 && !msgData.isRead"></view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			type: {
				type: Number,
				default: 1 // 1：申请添加好友添加消息  2：添加好友成功的系统通知 3：公告 4：聊天消息通知  5：点评消息通知
			},
			msgData:{
				type: Object,
				default(){
					return {}
				}
			}
		},
		data() {
			return {

			};
		},
		methods: {
			itemClk() {
               this.$emit('itemClk')
			}
		}
	}
</script>

<style lang="less">
	.msg-item {
		width: 630rpx;
		padding-top: 30rpx;
		padding-bottom: 20rpx;
		background-color: #FFFFFF;
		border-bottom: 2rpx solid #E8EFFE;
		position: relative;
	}

	.system-msg {
		.msg-title {
			font-size: 32rpx;
			font-weight: 500;
			color: #333333;
			line-height: 44rpx;
			margin-bottom: 16rpx;
		}

		.msg-time {
			font-size: 26rpx;
			font-weight: 400;
			color: #999999;
			line-height: 36rpx;
			margin-bottom: 10rpx;
		}

		.msg-text {
			font-size: 28rpx;
			font-weight: 400;
			color: #666666;
			line-height: 48rpx;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;

			.friend-name {
				font-weight: 600;
				color: #333;
				margin: 0 10rpx;
			}
		}
	}

	.user-msg {

		.user-msg-top {
			display: flex;
			margin-bottom: 24rpx;

			.user-avatar {
				width: 68rpx;
				height: 68rpx;
				border-radius: 50%;
				margin-right: 20rpx;
			}

			.msg-title-time {
				.msg-title {
					font-size: 32rpx;
					font-weight: 500;
					color: #333333;
					line-height: 44rpx;
					margin-bottom: 14rpx;

					.user-name {
						margin-right: 10rpx;
					}
				}

				.msg-time {
					font-size: 26rpx;
					font-weight: 400;
					color: #999999;
					line-height: 36rpx;
					margin-bottom: 10rpx;
				}
			}


		}

		.user-msg-text {
			font-size: 26rpx;
			font-weight: 400;
			color: #666666;
			line-height: 36rpx;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}

		.user-msg-num {
			position: absolute;
			width: 40rpx;
			height: 40rpx;
			border-radius: 50%;
			background-color: #FF4C4C;
			font-size: 24rpx;
			font-weight: 600;
			color: #FFFFFF;
			line-height: 40rpx;
			text-align: center;
			right: 12rpx;
			top: 80rpx;
		}
	}
	.msg-notread{
		position: absolute;
		width: 20rpx;
		height: 20rpx;
		border-radius: 50%;
		background-color: #FF4C4C;
		right: 12rpx;
		top: 90rpx;
	}
</style>
